//
//  QDCenterView.m
//  qidianchelian
//
//  Created by 冯贺 on 2018/4/20.
//  Copyright © 2018年 冯贺. All rights reserved.
//

#import "QDCenterView.h"

@implementation QDCenterView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self setUI];
    }
    return self;
}
-(void)setUI{
    
    _weatherImg = [[UIImageView alloc]init];
    _weatherImg.image = [UIImage imageNamed:@"晴天-白天"];
    [self addSubview:_weatherImg];
    
    _adressLabel = [[UILabel alloc]initWithTitle:@"" font:18*bili color:kBlackColor];
    [self addSubview:_adressLabel];
    
    _temperatureLabel = [[UILabel alloc]initWithTitle:@"" font:15*bili color:kBlackColor];
    [self addSubview:_temperatureLabel];
    
    _statusLabel = [[UILabel alloc]initWithTitle:@"" font:14*bili color:kLabelColor];
    [self addSubview:_statusLabel];
    
    UILabel * lineLabel = [[UILabel alloc]init];
    lineLabel.backgroundColor = kLabelColor;
    [self addSubview:lineLabel];
    
    _washLabel = [[UILabel alloc]initWithTitle:@"" font:14*bili color:kLabelColor];
    [self addSubview:_washLabel];
    
    UIImageView * restrictionsImg = [[UIImageView alloc]init];//限行背景图
    restrictionsImg.image = [UIImage imageNamed:@"restrictionsBack"];
    [self addSubview:restrictionsImg];
    
    _resLabel = [[UILabel alloc]initWithTitle:@"" font:16*bili color:kBlackColor];
    _resLabel.textAlignment = 1;
    [restrictionsImg addSubview:_resLabel];
    
    _dateLabel = [[UILabel alloc]initWithTitle:@"" font:14*bili color:kLabelColor];
    [self addSubview:_dateLabel];
    
    _weatherImg.sd_layout
    .leftSpaceToView(self, 15*bili)
    .centerYEqualToView(self)
    .widthIs(70*bili)
    .heightEqualToWidth();
    
    _adressLabel.sd_layout
    .leftSpaceToView(_weatherImg, 10*bili)
    .topSpaceToView(self, 15*bili)
    .heightIs(15*bili);
    [_adressLabel setSingleLineAutoResizeWithMaxWidth:(100)];
    
    _temperatureLabel.sd_layout
    .leftEqualToView(_adressLabel)
    .topSpaceToView(_adressLabel, 15*bili)
    .heightIs(15*bili);
    [_temperatureLabel setSingleLineAutoResizeWithMaxWidth:(100)];
    
    _statusLabel.sd_layout
    .leftEqualToView(_adressLabel)
    .topSpaceToView(_temperatureLabel, 15*bili)
    .heightIs(15*bili);
    [_statusLabel setSingleLineAutoResizeWithMaxWidth:(100)];
    
    lineLabel.sd_layout
    .leftSpaceToView(_statusLabel, 5)
    .topEqualToView(_statusLabel)
    .heightRatioToView(_statusLabel, 1)
    .widthIs(1);
    
    _washLabel.sd_layout
    .leftSpaceToView(lineLabel, 5)
    .topEqualToView(_statusLabel)
    .heightRatioToView(_statusLabel, 1);
    [_washLabel setSingleLineAutoResizeWithMaxWidth:(80)];
    
    _dateLabel.sd_layout
    .bottomSpaceToView(self, 10*bili)
    .rightSpaceToView(self, 10*bili)
    .heightIs(15*bili);
     [_dateLabel setSingleLineAutoResizeWithMaxWidth:(150)];
    
    restrictionsImg.sd_layout
    .centerXEqualToView(_dateLabel)
    .topSpaceToView(self, 10*bili)
    .widthIs(100*bili)
    .heightIs(70*bili);
    
    _resLabel.sd_layout
    .bottomSpaceToView(restrictionsImg, 15*bili)
    .widthRatioToView(restrictionsImg, 1)
    .heightIs(15*bili);
}

@end
